package net.samsb.tool;

import android.os.Message;

import net.samsb.BaseApplication;
import net.samsb.log.LogUtils;

import static net.samsb.activity.Constants.UPDATE_WS_CONNECT;

public class ReconnectionWSThread extends Thread {

    public volatile boolean isStop = false;

    @Override
    public void run() {
        super.run();

        while (!isStop) {
            try {
                LogUtils.e("ReconnectionWSThread", " --- ReconnectionWSRThread 启动 ");
                Thread.sleep(30 * 60 * 1000);

                if (BaseApplication.BaseWebSocket != null) {

                    LogUtils.e("getWebSocketMessage", "RECONNECT_重连");

                    BaseApplication.BaseWebSocket.close(4444,null);

                    BaseApplication.BaseRequestInstance.getWebSocketRequest().getWebSocketMessage(null);
                }

//                Message msg = new Message();
//                msg.what = UPDATE_WS_CONNECT;
//                msg.obj = "RECONNECT";
//                BaseApplication.mHandler
//                        .getHandlerWithName("MainActivity")
//                        .sendMessage(msg);

            } catch (InterruptedException e) {
                e.printStackTrace();
                LogUtils.e("getWebSocketMessage", "--- ReconnectionWSRThread 异常");
                return;
            }
        }
    }
}
